#include <stdio.h>

//#define STDIN
//#define DEBUG

int fv[102][102];
int c[102][102];
int F, V;
#define NINF -10000

void findMostValue()
{
    int i, j;
#ifdef DEBUG
    printf("F: %d V: %d\n", F, V);
    for (i = 1; i <= F; i += 1)
    {
        for (j = 1; j <= V; j += 1)
        {
            printf("%d ", fv[i][j]);
        }
        printf("\n");
    }
    printf("\n");
#endif
    for (i = 0; i <= F; ++i)
        for (j = 0; j <= V; ++j)
            c[i][j] = NINF;

    for (i = 1; i <= F; ++i)
    {
        for (j = i; j <= V - (F-i); ++j)
        {
            if (c[i-1][j-1] == NINF && c[i][j-1] == NINF)
                c[i][j] = fv[i][j];
            else if (c[i-1][j-1] == NINF && c[i][j-1] != NINF)
                c[i][j] = fv[i][j] > c[i][j-1] ?
                    fv[i][j]:
                    c[i][j-1];
            else if (c[i-1][j-1] != NINF && c[i][j-1] == NINF)
                c[i][j] = c[i-1][j-1] + fv[i][j];
            else

                c[i][j] = 
                    c[i-1][j-1] + fv[i][j] > c[i][j-1]?
                    c[i-1][j-1] + fv[i][j] :
                    c[i][j-1];
#ifdef DEBUG
            printf("====i: %d j: %d========\n", i, j);
            int m, n;
            for (m = 1; m <= F; ++m)
            {
                for (n = 1; n <= V; ++n)
                {
                    printf("%d\t", c[m][n]);
                }
                printf("\n");
            }
            printf("============\n");
#endif
        }
    }

    printf("%d\n", c[F][V] );
}


int main()
{
#ifdef STDIN
    freopen("bin/1157.in", "r", stdin);
#endif


    int i, j;
    scanf("%d %d", &F, &V);
    for (i = 1; i <= F; ++i)
    {
        for (j = 1; j <= V; ++j)
            scanf("%d", &fv[i][j]);
    }

    findMostValue();

    return 0;
}
